//
//  KDDStorage.h
//  MengLiao
//
//  Created by xiuxin on 2022/7/15.
//  Copyright © 2022 ZHBen. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "KDataDrivenProtocol.h"
#import "KDDUpdate.h"
#import "KDDUpdateBuilder.h"

@protocol KDDUpdateHandler <NSObject>

- (void)dataStorage:(id<KDataDrivenStorage>)storage willCommitUpdate:(KDDUpdate *)update;

- (void)dataStorage:(id<KDataDrivenStorage>)storage didCommitUpdate:(KDDUpdate *)update;
@optional
- (void)dataStorage:(id<KDataDrivenStorage>)storage performBatchUpdates:(void (^)(void))updates completion:(void (^)(BOOL finished))completion;

@end

@interface KDDStorage : KDDUpdateBuilder <KDataDrivenStorage,KDDUpdateReceiver>

- (instancetype)initWithData:(NSArray<KDDSectionData *> *)sectionDataList;

@property (weak,nonatomic) id<KDDUpdateHandler> updateHandler;

- (void)commitUpdate:(KDDUpdate *)update toData:(NSMutableArray<KDDSectionData *> *)data;

@end
